perm filename A79.TEX[106,PHY] blob sn#807785 filedate 1985-09-20 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\magnification\magstephalf
C00009 ENDMK
C⊗;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a79.tex[106,phy] \today\hfill}

\bigskip
\line{\bf Significant Digits.\hfill}

A number is said to have three {\sl significant digits\/} if it is the product
of an integer between 100 and 999 with a power of~10.

Examples:
\halign{\qquad$\lft{#}$\cr
100\qquad (100\times 10↑0)\cr
10000\qquad (100\times 10↑2)\cr
3.14\qquad (314\times 10↑{-2})\cr
0.0021\qquad (210\times 10↑{-5})\cr}

\noindent
For short, we say these are 3D numbers. Similarly, these are 10D
numbers:

\halign{\qquad$\lft{#}$\cr
3.141592654\cr
123456789\cr
0.02712712713\cr}

\noindent
There are several standard ways to write a number with a specified number
of significant digits. The most common are illustrated here:

\halign{\qquad$\lft{#}$\qquad&\lft{#}\qquad&\lft{#}\cr
1.00\times 10↑2&or&1.00E+02\cr
1.00\times 10↑4&or&1.00E+04\cr
3.14\times 10↑0&or&3.14E+00\cr
2.10\times 10↑{-3}&or&2.10E-03\cr}

\noindent
The left column, above, is called scientific notation. The right column is the
way Pascal prints 3D~numbers.

Many pocket calculators work with numbers having a certain number of signficant
digits. If asked to compute a number that is not in that set (for example
$123+4.56=127.56$, on a 3D~calculator), the calculator will instead
compute the nearest allowable answer to the correct one (128~in the example),
or the nearest allowable answer that is smaller in absolute value (127~in the
example).

Not many real computers work with the decimal representation of numbers,
but the qualitative effects of rounding errors are usually similar, so many
of our examples will assume a 3D~computer for simplicity, or an
8D~computer for comparable accuracy to many actual computers.

Most actual computers work with binary representations for numbers. The only
noticable effect this has on Pascal integers is that the largest possible
value ({\tt MAXINT}) is just under a power of~2, often
$2↑{35}-1=34359738355$. The Pascal {\tt REAL} numbers, though, are numbers
with a specified number of {\sl significant bits\/}. A~number with eight
significant bits (8B) is the product of an integer between 128
and~255 by a power of~2. The 8B numbers between 1 and~2 start with
$1=128\times 2↑{-7}$, $1{1\over 128}=129\times 2↑{-7}=1.0078125$,
$1{2\over 128}=130\times 2↑{-7}=1.015625$, and end with
$1{127\over 128}=255\times 2↑{-7}=1.9921875$, $2=128\times 2↑{-6}$.
An 8B~computer, asked to compute 1/3, would obtain
$170\times 2↑{-9}=0.33203\ldots$ or $171\times 2↑{-9}=0.33398\ldots$,
the true value being $170{2\over 3}\times 2↑{-9}$.

More realistically, a 27B~computer works with numbers which are the
product of an integer from $2↑{26}$ to $2↑{27}-1$ with a power of~2.
On such a machine, each {\tt REAL} number is an integer from 67108864 to
134217728, multiplied by a power of~2. The 27B~numbers between 1
and~2 include

\vfill\eject

\halign{\qquad$\lft{#}$\cr
2↑{26}\times 2↑{-26}=1\cr
(2↑{26}+1)\times 2↑{-26}=1.0000000149011\ldots\cr
(2↑{26}+2)\times 2↑{-26}=1.0000000298023\ldots\cr
\quad \vdots\cr
(2↑{27}-1)\times 2↑{-26}=1.9999999850988\ldots\cr
2↑{26}\times 2↑{-25}=2\cr}

\noindent
Asked to compute 1/3, such a machine would obtain $89478485\times 2↑{-28}$,
the true value being $89478485{1\over 3}\times 2↑{-28}$.

The difference between the exact answers and the computed ones in real
computers, typically 8D, 27B, or more, seems small, and usually
causes no harm. Nevertheless, the effects can be annoying:
{\tt WRITE}$(1/3+1/3+1/3)$ may print 9.9999999E-01, for example. Worse,
the cumulative effects of even such small errors may completely invalidate
the final results.

\bigskip
\line{\copyright 1985 Robert W. Floyd\hfill}
\line{First draft (not published) March 28, l985.\hfill}

\bye